function Ball(ctx, r) {
    this.ctx = ctx;
    this.r = r;
    this.fired = false;
}

Ball.prototype.init = function(x, y) {
    this.x = x;
    this.y = y;
    this.draw();
}

Ball.prototype.draw = function() {
    this.ctx.beginPath();
    this.ctx.fillStyle = "#ffc107";
    this.ctx.arc(this.x, this.y, this.r, 0, 2*Math.PI);
    this.ctx.fill();
}

Ball.prototype.fire = function() {
    this.speedX = 1;
    this.speedY = 2;
};

//这里应该加上小球掉落底端，游戏结束的逻辑。
Ball.prototype.move = function() {
    if(this.x >= 790 || this.x <= 10) {
        this.speedX = -this.speedX;
    }

    if(this.y <= 10) {
        this.speedY = -this.speedY;
    }

    //小球掉落，游戏结束（触发自定义游戏结束事件）
    if(this.y >=490) {
        $("body").trigger("gameover");
    }

    this.x += this.speedX;
    this.y -= this.speedY;
};